﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FDEE.Model
{
    /// <summary>
    /// Mokahali路基改桥专用600mm直径桩基--Bill-20220519
    /// </summary>
    public class BPile600 : PileBase
    {

        public BPile600(string typeName, string pierNumber, eSubType st, double len, double dia,double dowel) : base(typeName, pierNumber, st, len, dia)
        {

            DowelLen = dowel;
        }

        public override void SetRebarList()
        {
            eDB N1 = eDB.DB20;
            eDB N2 = eDB.DB20;
            eDB N3 = eDB.DB16;
            eDB N4 = eDB.DB12;

            #region N1-N2
            double Lap = 850.0;
            Debug.Assert(PileLength > 18000);
            Debug.Assert(PileLength <= 20000);
            double BaseLength = PileLength + DowelLen - Cover;
            int N2aL = (int)Math.Round(BaseLength - 12000 +  Lap, 0, MidpointRounding.AwayFromZero);
            int N2bL = N2aL + (int)Lap;
            Debug.Assert(N2bL <= 12000);
            RebarList = new RebarCollection();
            RebarList.Add(new MARebarRecord(1, 0, "a", N1, 12000, 4, eShapeType.Pile1a));    //1a 12m通长
            RebarList.Add(new MARebarRecord(1, 0, "b", N1, 12000-(int)Lap, 4, eShapeType.Pile1a));
            RebarList.Add(new MARebarRecord(1, 0, "c", N1, 12000, 6, eShapeType.Pile1a));
            RebarList.Add(new MARebarRecord(2, 0, "a", N2, N2aL, 4, eShapeType.Pile1a));
            RebarList.Add(new MARebarRecord(2, 0, "b", N1, N2bL, 4, eShapeType.Pile1a));
            #endregion

            #region N3
            int numN3 = (int)(PileLength / 2000) + 1;
            int N3Dia = (int)Diameter - (int)Cover * 2 - ((int)N4) * 2 - ((int)N1)*2 - ((int)N3);
            int N3L = (int)Math.Round(Math.PI * N3Dia + 300, 0, MidpointRounding.AwayFromZero);
            RebarList.Add(new MZRebarRecord(3, 0, "", N3, N3L, numN3, eShapeType.MY));
            #endregion

            #region N4
            double OD = Diameter - 2 * Cover;
            double LapN4 = 500;
            double HookN4 = 150;

            double L200 = 10450;
            double LS200top = PileBase.L2S(12000, OD, 200, ((int)N4), 0, LapN4, HookN4, HookN4, 1.5);
            double L12S200 = PileBase.L2S(12000, OD, 200, ((int)N4), 500, 500, HookN4, HookN4, 0);
            int NofMiddle =(int) ((L200 - LS200top) / L12S200);
            double LS200bot = L200 - LS200top - NofMiddle * L12S200;
            double L2 = PileBase.S2L(LS200bot, OD, 200, ((int)N4), 500, 500, HookN4, HookN4, 0);
            double L300 = PileLength - 10000;
            double L12S300 = PileBase.L2S(12000, OD, 300, ((int)N4), 500, 500, HookN4, HookN4, 0);
            int NofS300= (int) (L300 / L12S300);
            double LS300bot = L300 - NofS300 * L12S300;
            double L3 = PileBase.S2L(LS300bot, OD, 300, ((int)N4), 500, 0, HookN4, HookN4, 1.5);

            RebarList.Add(new MZRebarRecord(4, 1, "", N4, 12000, 1, eShapeType.MZ));
            RebarList.Add(new MZRebarRecord(4, 2, "", N4, 12000, NofMiddle, eShapeType.MZ));
            RebarList.Add(new MZRebarRecord(4, 3, "", N4, (int)L2, 1, eShapeType.MZ));
            RebarList.Add(new MZRebarRecord(5, 1, "", N4, 12000, NofS300, eShapeType.MZ));
            RebarList.Add(new MZRebarRecord(5, 2, "", N4, (int)L3, 1, eShapeType.MZ));
            #endregion


        }
    }
}
